package ma.ensao.egicom.core.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;

import ma.ensao.egicom.core.dto.CaddieLineDto;
import ma.ensao.egicom.core.dto.ProductDto; 
import net.sf.oval.constraint.NotBlank;
import net.sf.oval.constraint.NotNull;

import org.scub.foundation.framework.base.dto.AbstractDto;

public class CaddieDto extends AbstractDto implements Serializable {

    private Long id;

    @NotNull
    @NotBlank
    private ArrayList<CaddieLineDto> list;

    public ArrayList<CaddieLineDto> getLines() {
        return this.list;
    }

    public void setLines(ArrayList<CaddieLineDto> list) {
        this.list = list;
    }

    @Override
    public int hashCode() {
        int result = Arrays.hashCode(list.toArray());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        CaddieDto caddie = (CaddieDto) obj;
        ArrayList<CaddieLineDto> lines = caddie.getLines();
        Iterator i2 = this.list.iterator();
        Iterator i = lines.iterator();

        while (i.hasNext()) {
            CaddieLineDto cdto = (CaddieLineDto) i2.next();
            CaddieLineDto cdto2 = (CaddieLineDto) i.next();
            if (!cdto.equals(cdto)) {

                return false;
            }
        }

        return true;

    }
}
